package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-3-08
 * Time: 13:03
 */
/*class Login{
    private String userNume;
    private String passWord;

    public String getUserNume() {
        return userNume;
    }

    public void setUserNume(String userNume) {
        this.userNume = userNume;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public  void logInfo(String userNume, String passWord){
        if (!this.userNume.equals(userNume)){
            System.out.println("用户名错误...");
            return;
        }
        if (!this.passWord.equals(passWord)){
            System.out.println("密码错误...");
            return;
        }
        System.out.println("登录成功");
    }
}*/

class Login{
    private String userNume;
    private String passWord;

    public String getUserNume() {
        return userNume;
    }

    public void setUserNume(String userNume) {
        this.userNume = userNume;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public  void logInfo(String userNume, String passWord) throws UserNameException,
            PassWorlException{
        if (!this.userNume.equals(userNume)){
            throw new UserNameException("用户名错误异常...");
            /*System.out.println("用户名错误...");
            return;*/
        }
        if (!this.passWord.equals(passWord)){
            throw new PassWorlException("密码错误异常...");
            /*System.out.println("密码错误...");
            return;*/
        }
        System.out.println("登录成功");
    }
}

public class Test {
    public static void main(String[] args) {
        Login login = new Login();
        login.setUserNume("abc");
        login.setPassWord("123");

        try {
            login.logInfo("abc","123");
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PassWorlException e){
            e.printStackTrace();
        }finally {

        }

    }
}
